/* 
 * File:   oclFFT.h
 * Author: cbender
 *
 * Created on 5. September 2014, 16:21
 */

#ifndef OCLFFT_H
#define	OCLFFT_H
#include "structs.h"
#include "oclDistroFix.h"
#include <climits>
#include <inttypes.h>
#include <chrono>

class oclFFT {
public:
    // constructors, destructors
    oclFFT();
    oclFFT(const oclFFT& orig);
    virtual ~oclFFT();
    // Getters, setters
    void setInput(input_data* input);
    // Functions
    std::chrono::nanoseconds calculate(isotope* out);
private:
    double getGreatestAbsNegativeValue();
    void calculations();
    isotope* copyResult();
    void calculateMassRange();
    void calculateFrequency();
    void reset();
    void fft();
    void reverseBits(clcomplex* frequencyData);
    void convertMass();
    //Data Members:
    input_data* input;
    gpu_input_data* gpuInput;
    isotope* result;
    clcomplex* frequencyData;
    cl_context cxGPUContext;        // OpenCL context
    cl_command_queue cqCommandQueue;// OpenCL command que
    cl_platform_id cpPlatform;      // OpenCL platform
    cl_device_id cdDevice;          // OpenCL device
    cl_program cpProgram;           // OpenCL program
    cl_kernel ckKernel;             // OpenCL kernel1
    cl_kernel ckKernel2;             // OpenCL kernel2
    cl_int ciErr1;			// Error code var
    cl_int ciErr2;			// Error code var 2
    cl_mem d_gpuInput;               // OpenCL device source
    cl_mem d_input;               // OpenCL device source
    cl_mem d_frequencyData;
};

#endif	/* OCLFFT_H */

